package com.week2.day02;

import java.util.Random;

public class Weapon {
    private String name;
    private int damage;
    private int range;
    private double speed;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getDamage() {
        return damage;
    }

    public void setDamage(int damage) {
        this.damage = damage;
    }

    public int getRange() {
        return range;
    }

    public void setRange(int range) {
        this.range = range;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public Weapon() {
        this.name = "一把武器";
        this.damage = 100;
        this.range = 4;
        this.speed = 1;
    }

    public Weapon(String name, int damage, int range, double speed) {
        this.name = name;
        this.damage = damage;
        this.range = range;
        this.speed = speed;
    }

    public Weapon randomWeapon() {
        Random random = new Random();
        int i = random.nextInt(5);
        Weapon result ;
        switch (i) {
            case 0:
                result = new SniperRifle();
                break;
            case 1:
                result = new SickleBlade();
                break;
            case 2:
                result = new Flamethrower();
                break;
            case 3:
                result = new GravityGun();
                break;
            case 4:
                result = new Chakram();
                break;
            default:
                result = null;
        }
        return result;
    }

    @Override
    public String toString() {
        return "Weapon{" +
                "name='" + name + '\'' +
                ", damage=" + damage +
                ", range=" + range +
                ", speed=" + speed +
                '}';
    }
}
